public OnPlayerStateChange(playerid, newstate, oldstate) {
	if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) 
		SetPlayerArmedWeapon(playerid, 0);
	
	if ((oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) && GetPlayerVirtualWorld(playerid) == 0) 
		SendClientMessage(playerid, C_CYAN, "* You can repair your vehicle using '/vr'!");
    
    if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
        loop_players(i) {
            if (playerData[i][spectateId] == playerid && playerData[i][isSpectating] == true)
                PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
        }
    }
    
    if (newstate == PLAYER_STATE_ONFOOT) {
        loop_players(i) {
            if (playerData[i][spectateId] == playerid && playerData[i][isSpectating] == true)
                PlayerSpectatePlayer(i, playerid);
        }
    }
	
	return true;
}